'use strict';

const Service = require('egg').Service;

class UserService extends Service {
  constructor(ctx) {
    super(ctx);
  }
  async findById(id) {
    return await this.ctx.model.User.findById(id);
  }
  async create(post) {
    let user = new this.ctx.model.User(post);
    return await user.save();
  }
  async updatePassword(id, password) {
    return await this.ctx.model.User.where({_id: id}).update({ $set: {password: password} });
  }
}

module.exports = UserService;
